package com.shengyin.ec.model.dao.admin;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.shengyin.ec.model.dao.BaseDao;
import com.shengyin.ec.model.dao.BaseDaoImpl;
import com.shengyin.ec.model.dao.account.PersonalDao;
import com.shengyin.ec.model.entity.Company;
import com.shengyin.ec.model.entity.Personal;

@Repository("adminDao")
public class AdminDaoImpl extends BaseDaoImpl<Company> implements AdminDao  {

	public Company getCompanyByAdminName(String adminName){
		
		List<Company> list = super.find("from Company c where c.username='"+adminName+"'");
		System.out.println("====================list.get(0).getUsername()=================");

		System.out.println(list.get(0).getUsername());
		return list.get(0);
	}
	
	
	public boolean checkAdmin(String adminName, String pwd){
		
		try {
			ArrayList<Company> list = (ArrayList<Company>) super.find("From Company p where p.username='"+adminName+"' and p.pwd='"+pwd+"'");
			if(list.size()==0)
			   return false;
			else
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
}
